﻿using System;
using System.Web.UI.WebControls;
using MedicWeb.MedicService;

namespace MedicWeb.forms {
    public partial class JobList : SessionPage {
        protected void Page_Load(object sender, EventArgs e) {
            MainService ms = new MainService();
            Job[] jobList = ms.GetJobList(GetSession(), false);
            foreach (var job in jobList) {
                var row = new TableRow();
                TableCell cellEdit = new TableCell();
                TableCell cellId = new TableCell();
                TableCell cellRegion = new TableCell();
                TableCell cellJob = new TableCell();
                
                cellEdit.Controls.Add(new HyperLink() {CssClass = "edit modal", NavigateUrl = ResolveUrl("~/forms/Editors/Directory/JobEdit.aspx?id=" + job.Id) });
                cellEdit.Width = 24;
                cellId.Text = "" + job.Id;
                cellRegion.Text = job.JobCategory.Title;
                cellJob.Text = job.Title;

                row.Cells.Add(cellEdit);
                row.Cells.Add(createDeleteCell(job));
                row.Cells.Add(cellId);
                row.Cells.Add(cellRegion);
                row.Cells.Add(cellJob);

                tblJobs.Rows.Add(row);
            }
        }
    }
}